// miniprogram/pages/mall/home/index.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    loading: true,
    page: 1,
    dataList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //app.dataRequest("/rest/visitpage/visit.htm", {path:"my/home/index"},this,"visitData");

    if (options.id) {
      var param = {
        id: options.id
      };
      app.postRequestLoading("/rest/dynamicpage/view.htm", param, this.backDataView);
    }
    if (options.key) {
      var param = {
        key: options.key
      };
      app.postRequestLoading("/rest/dynamicpage/key.htm", param, this.backDataView);
    }
  },
  backDataView(res) {
    if (res.code == 0) {
      if (res.name) {
        wx.setNavigationBarTitle({
          title: '' + res.name,
          success: function (res) {},
          fail: function (res) {},
          complete: function (res) {},
        })
      }
      this.setData({
        items: res.items
      })
    }
  },
  loadingChange(e) {
    console.info(e);
    this.setData({
      loading: false
    });
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.setData({
      page: this.data.page + 1
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})